package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.axis.Axis;
import cn.limc.ohoscharts.view.GridChart;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.utils.Color;

import java.util.ArrayList;
import java.util.List;

public class GridChartAbility extends AbilitySlice {

  GridChart gridchart;

  @Override
  protected void onStart(Intent intent) {
    super.onStart(intent);
    super.setUIContent(ResourceTable.Layout_ability_grid_chart);
    initGridChart();

  }

//
//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu.grid_chart, menu);
//        return true;
//    }

  private void initGridChart() {
    this.gridchart = (GridChart) findComponentById(ResourceTable.Id_gridchart);

    List<String> ytitle = new ArrayList<String>();
    ytitle.add("241");
    ytitle.add("242");
    ytitle.add("243");
    ytitle.add("244");
    ytitle.add("245");
    List<String> xtitle = new ArrayList<String>();
    xtitle.add("9:00");
    xtitle.add("10:00");
    xtitle.add("11:00");
    xtitle.add("13:00");
    xtitle.add("14:00");
    xtitle.add("15:00");

    gridchart.setAxisXColor(Color.LTGRAY.getValue());
    gridchart.setAxisYColor(Color.LTGRAY.getValue());
    gridchart.setBorderColor(Color.LTGRAY.getValue());
    gridchart.setLatitudeNum(5);
    gridchart.setLongitudeNum(6);
    gridchart.setDataQuadrantPaddingTop(5);
    gridchart.setDataQuadrantPaddingBottom(5);
    gridchart.setDataQuadrantPaddingLeft(5);
    gridchart.setDataQuadrantPaddingRight(5);
    // gridchart.setAxisYTitleQuadrantWidth(50);
    // gridchart.setAxisXTitleQuadrantHeight(20);
    gridchart.setAxisXPosition(Axis.AXIS_X_POSITION_BOTTOM);
    gridchart.setAxisYPosition(Axis.AXIS_Y_POSITION_RIGHT);
    gridchart.getSimpleGrid().setLatitudeTitles(ytitle, null);
    gridchart.getSimpleGrid().setLongitudeTitles(xtitle, null);
    gridchart.setLongitudeFontSize(14);
    gridchart.setLatitudeFontSize(14);
    gridchart.setLongitudeFontColor(Color.WHITE.getValue());
    gridchart.setLatitudeColor(Color.GRAY.getValue());
    gridchart.setLatitudeFontColor(Color.WHITE.getValue());
    gridchart.setLongitudeColor(Color.GRAY.getValue());
    gridchart.setDisplayLongitudeTitle(true);
    gridchart.setDisplayLatitudeTitle(true);
    gridchart.setDisplayLatitude(true);
    gridchart.setDisplayLongitude(true);
    gridchart.setCrossLinesColor(Color.BLUE.getValue());
    gridchart.setCrossLinesFontColor(Color.GREEN.getValue());
    gridchart.setBorderWidth(1);
    // gridchart.setAxisWidth(1);
  }

}
